var t = require("../../../api.js"), a = getApp(), e = require("../../../utils/function.js");

Page({
    data: {
        img: e.userImg,
        driver: [],
        order: wx.getStorageSync("orderDetail"),
        satisfaction: [ "满意", "一般", "不满意" ],
        checkSatisfaction: -1,
        question: [],
        checkQuestion: [],
        idea: -1,
        order_no: "",
        graded: "",
        spendTime: 0,
        distance: 0,
        cid: 0,
        display: "none",
        display_1: "none",
        display_2: "none",
        display_3: "none",
        display_4: "none",
        display_5: "none",
        xing: 0
    },
    onLoad: function(t) {
        this.setData({
            order_no: t.order_no
        }), t.uid && a.shareCouponsMessage(t.uid);
    },
    satisfactionHandler: function(t) {
        this.setData({
            checkSatisfaction: t.currentTarget.dataset.id
        });
    },
    questionHandler: function(t) {
        console.log("获取订单号", t);
        for (var a = this.data.checkQuestion, e = this.data.question, s = t.currentTarget.dataset.id, i = 0; i < e.length; i++) s == i && (e[i].is_del = 0 == e[i].is_del ? 1 : 0);
        a.push(t.currentTarget.dataset.id), this.setData({
            checkQuestion: a,
            question: e,
            cid: t.currentTarget.dataset.cid
        });
    },
    ideaHandler: function(t) {
        console.log("一键", t), this.setData({
            idea: t.detail.value
        });
    },
    evaluateSubmitHandler: function() {
        for (var e = this, s = this.data.question, i = [], n = 0; n < s.length; n++) 1 == s[n].is_del && i.push(s[n].id);
        a.request({
            url: t.order_comment.order_comment,
            method: "post",
            data: {
                satisfaction: e.data.xing,
                cid: JSON.stringify(i.join(",")),
                idea: e.data.idea,
                driverid: e.data.driver.id,
                order_no: e.data.order_no
            },
            success: function(t) {
                console.log("意见提交", t.data), 1 == t.code ? wx.showModal({
                    title: "提示",
                    content: t.msg,
                    success: function(t) {
                        wx.navigateBack({
                            delta: 1
                        });
                    }
                }) : wx.showToast({
                    title: t.msg,
                    icon: "none"
                });
            }
        });
    },
    show_this: function(t) {
        var a = this;
        1 == t.target.dataset.num && (this.setData({
            display_1: "block"
        }), a.setData({
            xing: t.target.dataset.num
        })), 2 == t.target.dataset.num && (this.setData({
            display_1: "block",
            display_2: "block"
        }), a.setData({
            xing: t.target.dataset.num
        })), 3 == t.target.dataset.num && (this.setData({
            display_1: "block",
            display_2: "block",
            display_3: "block"
        }), a.setData({
            xing: t.target.dataset.num
        })), 4 == t.target.dataset.num && (this.setData({
            display_1: "block",
            display_2: "block",
            display_3: "block",
            display_4: "block"
        }), a.setData({
            xing: t.target.dataset.num
        })), 5 == t.target.dataset.num && (this.setData({
            display_1: "block",
            display_2: "block",
            display_3: "block",
            display_4: "block",
            display_5: "block"
        }), a.setData({
            xing: t.target.dataset.num
        })), console.log(t.target.dataset.num);
    },
    hide_this: function(t) {
        var a = this;
        5 == t.target.dataset.num && (this.setData({
            display_1: "block",
            display_2: "block",
            display_3: "block",
            display_4: "block",
            display_5: "block"
        }), a.setData({
            xing: t.target.dataset.num
        })), 4 == t.target.dataset.num && (this.setData({
            display_5: "none"
        }), a.setData({
            xing: t.target.dataset.num
        })), 3 == t.target.dataset.num && (this.setData({
            display_4: "none",
            display_5: "none"
        }), a.setData({
            xing: t.target.dataset.num
        })), 2 == t.target.dataset.num && (this.setData({
            display_3: "none",
            display_4: "none",
            display_5: "none"
        }), a.setData({
            xing: t.target.dataset.num
        })), 1 == t.target.dataset.num && (this.setData({
            display_2: "none",
            display_3: "none",
            display_4: "none",
            display_5: "none"
        }), a.setData({
            xing: t.target.dataset.num
        }));
    },
    testHandler: function(t, a) {
        if (-1 !== t) return !0;
        wx.showToast({
            title: a,
            icon: "none",
            duration: 2e3
        });
    },
    onShow: function() {
        var e = this;
        a.request({
            url: t.order_comment.getinfo,
            method: "post",
            data: {
                order_no: e.data.order_no
            },
            success: function(t) {
                console.log("sdsadsa", t), 1 == t.code ? e.setData({
                    question: t.data.problem,
                    driver: t.data.driver,
                    graded: t.data.graded,
                    spendTime: t.data.spendTime,
                    distance: t.data.distance
                }) : wx.showToast({
                    title: t.msg
                });
            }
        }), this.setData({
            driver: wx.getStorageSync("driverDetail"),
            order: wx.getStorageSync("orderDetail")
        });
    },
    onShareAppMessage: function() {
        return {
            title: a.shareAppMessage().title,
            imageUrl: a.shareAppMessage().imageUrl,
            desc: a.shareAppMessage().desc,
            path: a.shareAppMessage().path
        };
    }
});